<template>
	<view class="pageAll">
		<view v-if="dataInfo">
			<foodInfo :info="dataInfo" />
		</view>
		<view class="bottomBtnView" v-if="currTag === 2 && dataInfo">
			<button class="bottomBtn" hover-class="subActive" @click="withdraw">
				撤回
			</button>
		</view>
	</view>
</template>

<script>
	import foodInfo from '../../../components/foodReport/foodInfo.vue'
	export default {
		data() {
			return {
				currTag: null,
				dataInfo: null,
			}
		},
		methods: {
			withdraw() {
				this.$api.submissionWithdraw({
					id: this.dataInfo.id
				}).then(res => {
					if (res.status) {
						uni.showToast({
							title: '撤销提报成功',
						})
						this.$store.commit('setCurrTag', 1)
						setTimeout(() => {
							uni.switchTab({
								url: '../foodReport/foodReport'
							})
						}, 1500)

					} else {
						uni.showToast({
							title: '操作失败',
							icon: 'none',
						})
					}
				})
			},
			getInfo(id) {
				this.$api.submissionMessageIn({
					id: id,
				}).then(res => {
					if (res.status) {
						this.dataInfo = JSON.parse(JSON.stringify(res.data))
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration: 1500,
						})
					}
				})
			}
		},
		components: {
			foodInfo,
		},
		onLoad(option) {
			this.currTag = parseInt(option.currTag)
			if (option.id) {
				this.getInfo(option.id)
			}
		},
		onShareAppMessage: (options) => {
			// 设置菜单中的转发按钮触发转发事件时的转发内容
			var shareObj = {
				title: "红标HONBIAO", // 默认是小程序的名称(可以写slogan等)
				path: '/pages/indexPage/authorization/authorization', // 默认是当前页面，必须是以‘/’开头的完整路径
				imageUrl: '/static/index/labelRouge.png', //自定义图片路径，可以是本地文件路径、代码包文件路径或者网络图片路径，支持PNG及JPG，不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4
				success: (res) => {
					// 转发成功之后的回调
					if (res.errMsg == 'shareAppMessage:ok') {}
				},
				fail: () => {
					// 转发失败之后的回调
					if (res.errMsg == 'shareAppMessage:fail cancel') {
						// 用户取消转发
					} else if (res.errMsg == 'shareAppMessage:fail') {
						// 转发失败，其中 detail message 为详细失败信息
					}
				}
			};
			return shareObj
		},
	}
</script>

<style scoped>
	.pageAll {
		box-sizing: border-box;
		background-color: #fdf5f3;
		width: 100%;
		height: 100%;
		padding: 0 17upx;
		display: inline-block;
		position: fixed;
		overflow-y: auto;
	}

	.bottomBtnView {
		margin-top: 50upx;
		text-align: center;
		background-color: #fdf5f3;
		padding-bottom: 17upx;
	}

	.bottomBtn {
		width: 266.66upx;
		height: 66.66upx;
		background-color: #f7533e;
		color: #FFF;
		line-height: 66.66upx;
	}

	.bottomBtn:after {
		border: none;
	}

	.subActive {
		background-color: #ff0000 !important;
	}
</style>
